// forEach函数
function forEach(array, fn) {
    for (let i = 0; i < array.length; i++) {
        fn(array[i]);
    }
}
let arr = [1, 2, 3, 5, 6, 8, 10];
forEach(arr, (item) => {
    console.log(item);
});

// filter函数
function filter(array, fn) {
    let result = [];
    for (let i = 0; i < array.length; i++) {
        if (fn(array[i])) {
            result.push(array[i]);
        }
    }
    return result;
}

let r = filter(arr, (item) => {
    return item % 2 === 0;
});
console.log(r);